from CoreFoundation import CFRunLoopRun
from AudioToolbox import AudioQueueNewOutput

class CoreAudioDevice:
    def __init__(self, format: dict):
        self.queue = AudioQueueNewOutput(
            format,
            self._callback,
            None,
            CFRunLoopRun,
            None,
            0
        )

    def _callback(self, in_user_data, in_queue, in_buffer, in_start_time, in_num_packets, in_packet_desc):
        # 数据回调处理
        pass

    def start(self):
        """启动音频队列"""
        self.queue.Start()